package logic

import (
	"context"
	"doctor-medicine-system/api/internal/svc"
	"doctor-medicine-system/api/internal/types"
	"doctor-medicine-system/doctorrpc/doctorrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type MedSupplyAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewMedSupplyAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MedSupplyAddLogic {
	return &MedSupplyAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *MedSupplyAddLogic) MedSupplyAdd(req *types.MedSupplyAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	data, err := l.svcCtx.DoctorRpc.MedSupplyAdd(l.ctx, &doctorrpc.MedSupplyAddRequest{
		DoctorId:         req.DoctorId,
		MedSupplyName:    req.MedSupplyName,
		MedSupplyType:    req.MedSupplyType,
		MedSupplyAddress: req.MedSupplyAddress,
		MedSupplyComment: req.MedSupplyComment,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}

	return &types.Response{
		Message: "信息添加成功",
		Code:    200,
		Data:    data,
	}, nil
}
